class Solution {
public:
    vector<int> resultsArray(vector<int>& nums, int k)
    {
        if (k == 1) return nums;
        int n = nums.size();
        vector<int> ans(n - k + 1, -1);
        int cnt = 0;
        for (int i = 0; i < n; i++)
        {
            cnt = i == 0 || nums[i] == nums[i - 1] + 1 ? cnt + 1 : 1;
            if (cnt >= k) ans[i - k + 1] = nums[i];
        }
        return ans;
    }
};